﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using Qianwei.Model;
using Qianwei.Biz;
using Qianwei.Common.Extension;
using Qianwei.Common;

namespace Qianwei.Web.Admins
{
    public partial class ViewJobs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        #region Method
        private void BindData()
        {
            IList<job_info> joblist = JobInfoManager.Instance.QueryJobInfo(null, "Publish_Time desc");
            var newspager = Common.DataPaging<job_info>.GetDataSource(AspNetPager, joblist);
            r_jobs.DataSource = newspager;
            r_jobs.DataBind();
        }
        #endregion

        #region Event
        protected void AspNetPager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            AspNetPager.CurrentPageIndex = e.NewPageIndex;
            BindData();
        }

        protected void btnDel_Click(object sender, EventArgs e)
        {
            //Util.PageAlert(((Button)sender).CommandArgument);
            if (JobInfoManager.Instance.Delete(((Button)sender).CommandArgument.TryInt()))
            {
                Util.PageAlert("删除成功");
            }
            else
            {
                Util.PageAlert("对不起,删除失败");
            }
            DataBind();
        }
        #endregion
    }
}